package com.example.fbsmobile;

import com.example.fbsmobile.Booking;
import com.example.fbsmobile.R;

import java.util.List;

import android.net.Uri;
import android.os.Bundle;
import android.os.StrictMode;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleAdapter;

@SuppressLint("NewApi")
public class BookingHistoryActivity extends Activity implements
		OnItemClickListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.LAX);
		final ListView list = (ListView) findViewById(R.id.listView1);
		list.setOnItemClickListener(this);
		List<Booking> data = new BookingHistory().getBookingHistory();
		SimpleAdapter adapter = new SimpleAdapter(this, data,
				R.layout.list_booking, new String[] { "status", "facility",
						"startDate", "endDate" }, new int[] { R.id.textView1,
						R.id.textView2, R.id.textView3, R.id.textView4 });
		list.setAdapter(adapter);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

	@Override
	public void onItemClick(AdapterView<?> av, View arg1, int pos, long id) {
		// TODO Auto-generated method stub
		Booking book = (Booking) av.getAdapter().getItem(pos);		
		Intent intent = new Intent(this,BookingDetailsActivity.class);
		intent.putExtra("book", book);		
//		intent.putExtra("facility", "facility");
//		intent.putExtra("startDate", "startDate");
//		intent.putExtra("endDate", "endDate");
//		intent.putExtra("reason", "reason");
//		intent.putExtra("emergancy", "emergancy");
//		intent.putExtra("validatBy", "validateBy");
//		intent.putExtra("validateOn", "validateOn");
//		intent.putExtra("contactDetail", "contactDetail");
//		intent.putExtra("status", "status");
		intent.putExtra("check", "history");
		startActivity(intent);
	}

}
